package app.caihan.scframe.api.retrofit2


/**
 * 自定义错误信息异常
 *
 * @author Seven-C
 * @date 2020/8/20
 */
class ResponseThrowable : Exception {

    var code: Int//错误码
    var errMsg: String//错误消息
    var errLog: String? //错误日志

    constructor(error: ERROR, e: Throwable? = null) : super(e) {
        this.code = error.getKey()
        this.errMsg = error.getValue()
        this.errLog = e?.message
    }

    constructor(code: Int, msg: String, e: Throwable? = null) : super(e) {
        this.code = code
        this.errMsg = msg
        this.errLog = e?.message
    }

    constructor(base: IBaseResponse<*>, e: Throwable? = null) : super(e) {
        this.code = base.code()
        this.errMsg = base.msg()
        this.errLog = e?.message
    }

    override fun toString(): String {
        return "ResponseThrowable :: code = $code errMsg = $errMsg errLog = $errLog"
    }
}

